package jp.co.hcs.attendancemanagement.inputdailyattendance.logic;

import java.sql.SQLException;

import jp.co.hcs.attendancemanagement.data.entity.WorkingTimeMaster;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.TimeSettingInitDTO;
import jp.co.hcs.attendancemanagement.logic.LogicBase;
import jp.co.hcs.attendancemanagement.util.DateUtil;

public class GetWorkingTimeInfoLogic extends LogicBase {
    /**
     * Gets the working time by id.
     * 
     * @param workingTimeId the working time id
     * @return the working time by id
     * @throws SQLException the sQL exception
     */
    public TimeSettingInitDTO getWorkingTimeById(String workingTimeId) throws SQLException {
      WorkingTimeMaster workingTimeMaster =
          daoFactory.getWorkingTimeMasterDAO().selectWorkingTimeMasterByPrimaryKey(workingTimeId);
      TimeSettingInitDTO workingTimeDto = new TimeSettingInitDTO();
      workingTimeDto.setWorkingTimeCode(workingTimeMaster.getWorkingTimeId());
      workingTimeDto.setWorkingTimeName(workingTimeMaster.getWorkingtimeName());
      workingTimeDto.setStartTime(DateUtil.convertDateToHourFormat(workingTimeMaster.getStartTime()));
      workingTimeDto.setEndTime(DateUtil.convertDateToHourFormat(workingTimeMaster.getEndTime()));
      workingTimeDto.setFixedWorkingTime(DateUtil.convertDateToHourFormat(workingTimeMaster
          .getFixedWorkingTime()));
      workingTimeDto.setOvertimeAutoApplyTime(DateUtil.convertDateToHourFormat(workingTimeMaster
          .getAutoOvertimeTime()));
      return workingTimeDto;
    }
}
